// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store/index'
import './components/vcomponent'
import './assets/js/jquery-3.0.0.min.js'
import {
    getConfig
} from './components/wxConfig.js'

Vue.config.productionTip = false


/* eslint-disable no-new */
window.vm = new Vue({
    el: '#app',
    router,
    store,
    template: '<App/>',
    components: {
        App
    },
    data:{
        userName:"",
        phoneNo:""
    },
    watch: {
        '$route' (to, from) {
            console.dir(to)
            if(to.name == "Pselection" || to.name == "Record" || to.name == "UserInfo"){
                store.state.headerTitle = "尊敬的" + this.userName +",你好"
            }else if(to.name == "Fillinfo"){
                store.state.headerTitle = "填写验证人信息"
            }else if(to.name == "Contract") {
                store.state.headerTitle = "万鉴通征信服务协议"
            }else if(to.name == "Process"){
                store.state.headerTitle = "人脸识别"
            }
        }
    },
    beforeCreate: function() {
        getConfig(getAppidSignServlet, {
            "url": location.href
        }, ['chooseImage', 'uploadImage', 'downloadImage', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'uploadVoice', 'chooseVideo', 'uploadVideo', 'downloadVideo']);
        console.log("beforeCreate......")
    },
    beforeMount: function() {
        var _this = this;
        $.post(homeServlet, {}, function(hdata) {
            console.log("homeServlet data")
            console.dir(hdata);
            if (hdata.code == "0000" && hdata.data) {
                _this.userName = hdata.data.userName;
                store.state.userName = hdata.data.userName;
                store.state.userPhone = hdata.data.phoneNo;
                store.state.headerTitle = "尊敬的" + hdata.data.userName +",你好"
            }
        });
    }

})

vm.$on("$alert",function  (content) {
    store.state.isAlert = true;
    console.log("$alert samething" + content)
})
